package com.yootk.dao.impl;

import com.yootk.common.dao.abs.AbstractDAO;
import com.yootk.dao.IMessageDAO;
import com.yootk.vo.Message;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 * 数据层实现类
 */
public class MessageDAOImpl extends AbstractDAO implements IMessageDAO {
    @Override
    public boolean doCreate(Message message) throws SQLException {
        return false;
    }

    @Override
    public boolean doEdit(Message message) throws SQLException {
        return false;
    }

    @Override
    public boolean doRemove(Set<Long> longs) throws SQLException {
        return false;
    }

    @Override
    public Message findById(Long aLong) throws SQLException {
        return null;
    }

    @Override
    public List<Message> findAll() throws SQLException {
        List<Message> messageList = new ArrayList<>();
        String sql = "SELECT id, title, content FROM message";
        super.pstmt = super.connection.prepareStatement(sql);
        ResultSet rs = super.pstmt.executeQuery();
        while (rs.next()) {
            Message msg = new Message();
            msg.setId(rs.getLong(1));
            msg.setTitle(rs.getString(2));
            msg.setContent(rs.getString(3));
            messageList.add(msg);
        }
        return messageList;
    }

    @Override
    public List<Message> findSplit(Integer currentPage, Integer lineSize) throws SQLException {
        return null;
    }

    @Override
    public List<Message> findSplit(Integer currentPage, Integer lineSize, String column, String keyword) throws SQLException {
        return null;
    }

    @Override
    public Long getAllCount() throws SQLException {
        return null;
    }

    @Override
    public Long getAllCount(String column, String keyword) throws SQLException {
        return null;
    }
}
